﻿@model IEnumerable<Hospital>
@{
    var CV = Request["cv"];
    var CT = Request["ct"];
    }           
<div style="height: 400px; overflow: auto;" id="treeselectroot">
    <ul >
        <li>
            <div class="catalog-title">
                常规随访选择:全部医院</div>
            <ul>
                @foreach (var h in Model)
                {
                    <li class='closed'>
                        <div>
                            @Html.DisplayFor(m => h.HospName)
                        </div>
                        @if (h.BingQus.Count > 0)
                        { 
                            <ul>
                                @foreach (var b in h.BingQus)
                                {
                                    <li class='closed'>
                                        <div>
                                            @Html.DisplayFor(m => b.Title)
                                        </div>
                                        @if (b.Departments.Count > 0)
                                        { 
                                            <ul>
                                                @foreach (var d in b.Departments)
                                                {
                                                    <li>
                                                        <div>
                                                            <a class='sel' href="#" value="@(d.DepartmentID)" title="@(string.Format("{0}{1}{2}",h.HospCode,b.Title,d.DepName))">@d.DepName</a>
                                                        </div>
                                                    </li>
                                                }
                                            </ul>
                                        }
                                    </li>
                                }
                            </ul>
                        }   
                    </li>
                }
            </ul>
        </li>
    </ul>
</div>
<script type="text/javascript">
    $(function () {
        $("#treeselectroot").treeview();
        $('#treeselectroot a.sel').click(function () {
            $('#@(CT)').val($(this).attr("title"));
            $('#@(CV)').val($(this).attr("value"));
            $("#treeviewselector").dialog('close');
            //$("#treeviewselector").dialog('destroy');

            return false;
        });

    });
</script>
